<template>
  <div class="userInfoPage">
    <div class="rotue-left">
      <div class="userInfoBox">
        <div class="userPic">
          <img v-lazy="headPic" />
        </div>
        <div
          class="userName"
          :title="userInfo.nickName || userInfo.regName || userInfo.email"
        >
          {{ userInfo.nickName || userInfo.regName || userInfo.email }}
        </div>
        <div
          style="
            margin-top: 11px;
            display: flex;
            align-items: flex-start;
            justify-content: center;
            flex-flow: wrap;
            max-width: 90%;
          "
        >
          <div
            class="authentication"
            v-for="(item, index) in this.userInfo.authName"
            :key="index"
          >
            {{ item }}
          </div>
        </div>
      </div>
      <Menu :data="pageData" />
    </div>
    <div style="flex: 1">
      <USERINFO v-if="pageName == 'info'" />
      <ACCOUNTBIND v-if="pageName == 'bind'" />
      <COURSELIST v-if="pageName == 'list'" />
      <OUTCOMESUPLOAD v-if="pageName == 'oUpload'" />
      <!-- <OUTCOMESREVIEW v-if="pageName == 'oReview'" /> -->
      <!-- <COURSEDETAIL v-if="pageName == 'cDetail'" /> -->
    </div>
  </div>
</template> 

<script>
import { mapState } from "vuex";
import { location } from "@/util/tool";
const Menu = () => import("@/views/user/user/component/menu");
const USERINFO = () => import("@/views/user/user/userInfo/userInfo");
const ACCOUNTBIND = () => import("@/views/user/user/userInfo/accountBind");
const COURSELIST = () => import("@/views/user/user/stuOutcomes/courseList");
const OUTCOMESUPLOAD = () =>
  import("@/views/user/user/stuOutcomes/outcomesUpload");
// const OUTCOMESREVIEW = () =>
//   import("@/views/user/user/stuOutcomes/outcomesReview");
// const COURSEDETAIL = () => import("@/views/user/user/stuOutcomes/courseDetail");
import { pageNameInit } from "./index";
export default {
  components: {
    Menu,
    USERINFO,
    ACCOUNTBIND,
    COURSELIST,
    OUTCOMESUPLOAD,
    // OUTCOMESREVIEW,
    // COURSEDETAIL,
  },
  data() {
    return {
      pageName: "",
      pageData: [
      {
          path: "aSetting",
          title: "个人资料",
          children: [
            {
              path: "bind",
              title: "基本资料",
            },
            {
              path: "info",
              title: "详细资料",
            },
          ],
        },
        {
          path: "sOutcomes",
          title: "学业展示",
          children: [
            {
              path: "list",
              title: "我的课程",
            },
            {
              path: "oUpload",
              title: "学业管理",
            },
          ],
        },
      ],
    };
  },
  computed: {
    ...mapState({
      userInfo: (state) => state.user.userInfo,
    }),
    headPic() {
      return this.userInfo.iconPath === "/iconPath.png"
        ? require("@/assets/images/headPic.svg")
        : this.userInfo.iconPath;
    },
  },
  watch: {
    $route(n) {
      if (n.query.pageName) this.pageName = n.query.pageName;
      else this.initRoutePageName()
    },
  },
  created() {
    this.pageName = pageNameInit(this.$route, this.pageData);
    this.initRoutePageName()
  },
  methods: {
    initRoutePageName() {
      const { path, query } = this.$route;
      if (query.pageName)
        this.$router.push({ path: path, query: { pageName: query.pageName } });
      else this.$router.push({ path: path, query: { pageName: this.pageName } });
    },
  },
  mounted() {
    this.initRoutePageName()
  },
};
</script>

<style lang="stylus">
.userInfoPage {
  padding: 30px 0;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;

  .rotue-left {
    width: 220px;
    height: 729px;
    background-color: rgba(246, 246, 246, 0.95);
    border-radius: 5px;

    .userInfoBox {
      padding-top: 57px;
      height: 300px;
      display: flex;
      flex-flow: column;
      justify-content: flex-start;
      align-items: center;

      .userPic {
        width: 92px;
        height: 92px;
        // background-color: rgba(228, 228, 228, 0.5);
        border: solid 4px rgba(255, 255, 255, 0.81);
        border-radius: 50%;
        overflow: hidden;

        img {
          object-fit: cover;
          height: 100%;
          width: 100%;
        }
      }

      .userName {
        margin-top: 9px;
        padding: 0 5px;
        min-width: 160px;
        max-width: 80%;
        height: 24px;
        line-height: 24px;
        text-align: center;
        background-color: #ededed;
        font-family: Segoe UI;
        font-size: 18px;
        color: rgba(109, 108, 108, 0.66);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .idBox {
        margin-top: 10px;
        padding: 0 15px;
        font-family: Segoe UI;
        font-size: 12px;
        color: #999898;
      }

      .authentication {
        margin-top: 10px;
        margin-right: 5px;
        width: fit-content;
        display: inline-block;
        height: 21px;
        padding: 1px 2px;
        line-height: 21px;
        background-color: #fea91b;
        border-radius: 5px;
        font-family: PMingLiU-ExtB;
        font-size: 14px;
        color: #fff;
      }

      .listBox {
        margin-top: 14px;
        padding: 0 40px 0 31px;
        display: flex;
        justify-content: space-between;
        width: 100%;

        img {
          width: 26px;
          height: 26px;
        }
      }
    }

    .routesBox {
      height: 429px;

      .title {
        padding-bottom: 12px;
        margin: 0 28px 0 27px;
        font-family: Segoe UI;
        // font-weight: bold;
        font-size: 19px;
        color: #666666;
        border-bottom: solid 1px rgba(206, 203, 203, 0.54);
      }

      .listBox {
        margin-top: 13px;

        .route {
          cursor: pointer;
          padding-right: 22px;
          padding-left: 63px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          height: 48px;
          line-height: 48px;
          text-align: center;
          font-family: Segoe UI;
          font-size: 18px;
          color: #8b8b8b;
        }

        .is-active {
          background-color: #f6061e;
          color: #fff;
        }
      }
    }
  }
}
</style>